﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPIUI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UpLoadController : ControllerBase
    {
        /// <summary>
        /// 文件上传功能
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        [HttpPost]
        public dynamic UpLoad(IFormFile file)
        {
            var res = Directory.GetCurrentDirectory() + @"\wwwroot\img" + file.FileName;
            using(FileStream fs=new FileStream(res, FileMode.Create))
            {
                file.CopyTo(fs);
                fs.Close();
            }
            return Ok("https://localhost:7052/img"+file.FileName);
        }
    }
}
